<template>
	<view class="container-white">
		<view class="head">
			<view>交卷时间：{{info.submitPaperTime}}</view>
			<view>是否通过：<span v-if="parseInt(this.isPass) == 1">已通过</span>
				<span v-else>未通过</span>
			</view>
		</view>
		<view style="text-align: center;margin-top: 10upx;margin-bottom: 40upx;display: flex;flex-direction: column;justify-content: center;align-items: center;">
			<view class="score-circle">
				<view style="color: #999999;margin-top: 46upx;">分数</view>
				<view>
					<text style="color: #333333;font-size: 72upx;">{{info.sumScore}}</text>
					<text style="color: #666666;margin-left: 20upx;">分</text>
				</view>
			</view>
			<view style="font-size:28upx;color:#999999;">答对：{{info.quesRight}}题</view>
		</view>
		<view>
			<view style="display: flex;flex-wrap: wrap;padding: 0 20upx;">
				<view class="options" v-for="(item,index) in scantron" :key="index">
					<view class="stide" :class="item.answ ?(item.answ == item.rightAnsw?'correct':'mistake'):''" @tap="wrongTopic(item,index)">{{index+1}}</view>
					<!-- <view class="stide" :class="item.answ ?(item.answ == item.rightAnsw?'correct':'mistake'):''">{{index+1}}</view> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		post_md5
	} from '../../common/request'
	export default {
		data() {
			return {
				info: {},
				scantron: [],
				tag: true,
				total: '',
				isPass: ''
			}
		},
		onLoad(options, id) {
			console.log(options)
			// setNavTitle(options.name)
			this.goExamRecord(options.resourceId)
			this.tag = options.tag
			if (options.tag) {
				// #ifdef APP-PLUS
				var webView = this.$mp.page.$getAppWebview()
				webView.setTitleNViewButtonStyle(0, {
					text: '\ue6ae'
				})
				// #endif
			}
		},
		// onLoad(options) {
		// 	console.log(options)
		// 	this.scantron = JSON.parse(options.list)
		// 	this.duration = options.duration
		// 	for (let i = 1; i <= Number(options.idx); i++) {
		// 		this.num.push({num:i,checked:false})
		// 	}
		// 	for(let i in this.scantron){
		// 		this.num[i].checked = this.scantron[i].checked
		// 	}
		// 	// this.getScantron(options)
		// 	// this.num = Number(options.idx)
		// 	this.params = JSON.parse(options.params)
		// 	this.timer = setInterval(() => {
		// 		this.duration = this.duration - 1
		// 		if (this.duration === 0) {
		// 			clearInterval(this.timer)
		// 			this.confirm()
		// 		} else {
		// 			this.remainingTime = formatSeconds(this.duration)
		// 		}
		// 	}, 1000)
		// },
		methods: {
			goExamRecord(resourceId) {
				const params = {
					userId: uni.getStorageSync('userId'),
					examId: resourceId
				}
				post_md5('/train-app/courseexam/examRecord', params).then(res => {
					this.isPass = res.data.isPass
					this.info = res.data
					this.scantron = res.data.listResult
					this.total = res.data.listResult.length
				})
			},

			// 查看题目
			wrongTopic(item, index) {
				console.log(item)
				uni.navigateTo({
					url: 'answer?quesId=' +
						item.quesId +
						'&id=' +
						item.id +
						'&examId=' +
						item.examId +
						'&index=' +
						index + '&total=' + this.total
				})
			}
			// wrongTopic(item, index) {
			// 	console.log(item)
			// 	uni.navigateTo({
			// 		url: `answer?id=${item.id}&total=${this.scantron.length}&index=${index}`
			// 	})
			// },
		}
	}
</script>

<style>
	.head {
		font-size: 28upx;
		font-family: HiraginoSansGB-W3;
		font-weight: normal;
		color: #666666;
		border-top: 1px solid #ededed;
		padding: 20upx;
		line-height: 40upx;
	}

	.score-circle {
		width: 230upx;
		height: 230upx;
		border: 1px solid #999999;
		border-radius: 50%;
		font-size: 28upx;
		margin-bottom: 20upx;
		/* text-align: center; */
	}

	.options {
		width: 118upx;
		display: flex;
		justify-content: center;
	}

	.stide {
		margin: 0;
	}

	.correct {
		background: #3ed325;
		color: #ffffff;
		border: 1px #3ed325 solid;
	}

	.mistake {
		background: #ec6663;
		color: #ffffff;
		border: 1px #ec6663 solid;
	}
</style>
